package com.example.stumanager.admin;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import com.example.stumanager.R;
import com.example.stumanager.database.UserSql;

/**
 * 删除学生
 */
public class AdminDelStudentsPage extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.admin_del_students_page);

        TextView info=findViewById(R.id.info);
        EditText id=findViewById(R.id.id);
        UserSql db=new UserSql(this);

        Button re=findViewById(R.id.re);
        re.setOnClickListener(view -> finish());

        Button d=findViewById(R.id.d);
        d.setOnClickListener(view -> {
            if(db.delById(id.getText().toString())){
                Toast.makeText(AdminDelStudentsPage.this, "删除成功", Toast.LENGTH_SHORT).show();
                info.setText("删除成功");
                finish();
            }else{
                Toast.makeText(AdminDelStudentsPage.this, "学号不存在", Toast.LENGTH_SHORT).show();
                info.setText("学号不存在，删除失败");
            }


        });

    }
}